# @Time    : 2022/7/16 11:49
# @Author  : mobai
# @Email   : 3111283671@qq.com
# @File    : khtj_page.py
# @Software: PyCharm

from pages.kehu_page import KeHuPage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from time import sleep


class KhtjPage(KeHuPage):
    """合同统计页面"""
    url = "http://192.168.1.151/crm/index.php?m=customer&a=analytics"
    XZYG = (By.ID, "role")
    DJSS = (By.XPATH, "//*[@id='searchForm']/ul/li[4]/button")
    LYTJ = (By.ID, "show_source")
    GDXX = (By.CSS_SELECTOR, '#highcharts-0 > svg > g.highcharts-button')
    DYTB = (By.XPATH, "//*[@id='highcharts-0']/div/div/div[1]")

    def xzyg(self,xzyg):
        """选择员工admin"""
        locator = self.driver.find_element(*self.XZYG)
        select = Select(locator)
        select.select_by_visible_text(xzyg)

    def djss(self):
        """点击搜索"""
        self.driver.find_element(*self.DJSS).click()

    def lytj(self):
        """点击来源统计图"""
        self.driver.find_element(*self.LYTJ).click()
        sleep(2)

    def gdxx(self):
        """点击更多选项"""
        self.driver.find_element(*self.GDXX).click()

    def dytb(self):
        """点击打印图标"""
        self.driver.find_element(*self.DYTB).click()
        sleep(1)

